<!-- 测试页面 -->

<template>
  <div>
    <h1>Users</h1>
    <ul>
      <!-- <li v-for="user in users" :key="user.id">{{ user.name }}</li> -->
      <li>{{ user }}</li>
    </ul>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue';
import { getUsers, getUser } from '../../api/user';

export default {
  name: 'HomeView',
  setup() {
    const user = ref();

    const fetchUsers = async () => {
      try {
        const response = await getUser(1);
        user.value = response.data;
      } catch (error) {
        console.error(error);
      }
    };

    onMounted(fetchUsers);

    return {
      user,
    };
  },
};
</script>
